package ltk.servlet;


import hezi.common.ExtractTask;
import hezi.core.ExtractHelper;
import hezi.core.Post;
import hezi.helper.ScanAllThread;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.Template;

public class TestServlet extends BaseServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		super.doGet(request, response);
		String action = request.getParameter("action");
		if(null == action || action.length() < 2){
			defaultpage(request);
			return;
		}

		if(action.equals("runpost")){
			String posturl = request.getParameter("posturl");
			Post post = new Post();
			
			post.postid = "0";
			post.forumid = "testforumid";
			post.siteid = "testsiteid";
			post.setPosturl(posturl);
			
			ExtractTask task = new ExtractTask(post);
			
			ExtractHelper extractHelper = new ExtractHelper(post);
			extractHelper.postPopulate();
			
//			task.postLoad();
			
			writeout("ok");
			
		}
		
	}
	

	private void defaultpage(HttpServletRequest request) {
		Template t = ve.getTemplate("test.html");
		writeout(t);
	}

}
